package org.etlt.extract;

import org.etlt.SettingCheck;
import org.etlt.SettingValidationException;

public class FileExtractSetting extends ExtractorSetting{

    private String delim = ",";

    private String dataSource;

    private String encoding = ExtractorSetting.UTF_8;

    public String getDelim() {
        return delim;
    }

    public void setDelim(String delim) {
        this.delim = delim;
    }

    public String getDataSource() {
        return dataSource;
    }

    public void setDataSource(String dataSource) {
        this.dataSource = dataSource;
    }

    @Override
    public void check(){
        super.check();
        if(getColumns().size() == 0)
            throw new SettingValidationException("extractor columns definition missing: " + getName() );
        getColumnSettings().forEach(setting -> {
            if(setting instanceof SettingCheck){
                ((SettingCheck)setting).check();
            }
        });
    }

    public String getEncoding() {
        return encoding;
    }

    public void setEncoding(String encoding) {
        this.encoding = encoding;
    }
}
